package com.event.service.impl;

import com.event.pojo.StudySrc;
import com.event.mapper.StudySrcMapper;
import com.event.service.StudySrcService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 学习资料模块 服务实现类
 * </p>
 *
 * @author 孤雏
 * @since 2021-12-31
 */
@Service
public class StudySrcServiceImpl extends ServiceImpl<StudySrcMapper, StudySrc> implements StudySrcService {
    @Autowired
    StudySrcMapper studySrcMapper;

    @Override
    @Cacheable(value = "StudySrc")
    public List<StudySrc> selectStudySrc(StudySrc studySrc) {
        return studySrcMapper.selectStudySrc(studySrc);
    }

    @Override
    @CacheEvict(value = "StudySrc", allEntries = true)
    @Transactional
    public boolean deleteStudySrc(Long srcId) {
        return removeById(srcId);
    }

    @Override
    @CacheEvict(value = "StudySrc", allEntries = true)
    @Transactional
    public int insertStudySrc(StudySrc studySrc) {
        return studySrcMapper.insert(studySrc);
    }

    @Override
    @CacheEvict(value = "StudySrc", allEntries = true)
    @Transactional
    public int updateStudySrc(StudySrc studySrc) {
        return studySrcMapper.updateStudySrc(studySrc);
    }

    @Override
    @Cacheable(value = "StudySrc")
    public List<StudySrc> selectStudySrcByName(String srcName) {
        return studySrcMapper.selectStudySrcByName(srcName);
    }

}
